

********* This program generates the results in Table 4 of the paper: effects of shocks to first degree links *********

clear all
set more off, permanently
cd "$localdir\Data"
global output "$localdir\Output"




***** Prepare "first stage" data ********

use "First stage.dta", clear

* Sample restrictions

* Not same muni
drop if muni==muni_network

* Age range
merge m:1 unique_network year using "Age (network).dta"
drop if _merge==2
drop if age_network>65 | age_network<20
drop _merge age_network

* Get industry, occupation, and education for fixed effects
* Preferred specification: industry 2d-occupation 1d-year, education 1d-year, and parish-year fixed effects
merge m:1 unique year using "Industry codes.dta", keepusing(industry_code_2_digit)
replace industry_code_2_digit = 999 if _merge==1 
drop if _merge==2
drop _merge

merge m:1 unique year using "Occupation codes.dta", keepusing(occupation_code_1_digit)
replace occupation_code_1_digit = 999 if _merge==1 
drop if _merge==2
drop _merge 

merge m:1 unique year using "Education codes.dta", keepusing(educ_code_1_digit)
replace educ_code_1_digit = 999 if _merge==1 
drop if _merge==2
drop _merge 

* FE groups
egen ind2_year = group(industry_code_2_digit year)
egen ocp_year = group(occupation_code_1_digit year)
egen educ_year = group(educ_code_1_digit year)
egen ind2_ocp_year = group(industry_code_2_digit occupation_code_1_digit year)

g gov_solution = preferred_econ_policy==2 | preferred_econ_policy==5 if preferred_econ_policy!=. 
drop preferred_econ_policy

* Weights: define new weights specific to each regression sample
drop network_size

save "First stage for Analysis.dta", replace



***************************************************** ASSESSMENT OF NATIONAL UNEMPLOYMENT RATE ******************************************************

* Outcome only available in 2011 and 2012

use "First stage for Analysis.dta", clear

keep unique unique_network unemp_rate_estimate grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if unemp_rate_estimate!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

replace unemp_rate_estimate=unemp_rate_estimate/100

* Results
display c(current_time)
reghdfe unemp_rate_estimate grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum unemp_rate_estimate if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", replace nocons nor ctitle("Guess national unemployment rate") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)









***************************************************** FORECAST OF NATIONAL UNEMPLOYMENT RATE ******************************************************

* Outcome only available in 2011

use "First stage for Analysis.dta", clear

keep unique unique_network unemp_rate_estimate_next grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if unemp_rate_estimate_next!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

replace unemp_rate_estimate_next=unemp_rate_estimate_next/100

* Results
display c(current_time)
reghdfe unemp_rate_estimate_next grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum unemp_rate_estimate_next if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("National unemployment rate expectation") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)







***************************************************** UNEMPLOYMENT OUTCOMES - PROBABILITY ******************************************************

use "First stage for Analysis.dta", clear

keep unique unique_network prob_unemployed grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if prob_unemployed!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

replace prob_unemployed=prob_unemployed/100

* Results
display c(current_time)
reghdfe prob_unemployed grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum prob_unemployed if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Own unemployment expectation") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)





***************************************************** UNEMPLOYMENT OUTCOMES - UI POLICY ******************************************************

use "First stage for Analysis.dta", clear

keep unique unique_network more_ui grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if more_ui!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

* Results
display c(current_time)
reghdfe more_ui grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum more_ui if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Want more unemployment insurance") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)








***************************************************** IDEOLOGY OUTCOMES ******************************************************

use "First stage for Analysis.dta", clear

keep unique unique_network govt_more_help hard_work grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if govt_more_help!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

* Results
display c(current_time)
reghdfe govt_more_help grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum govt_more_help if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Government should support the poor") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)











***************************************************** ECONOMIC POLICY ******************************************************

* These questions were not asked in 2012

use "First stage for Analysis.dta", clear

keep unique unique_network gov_solution not_enough grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if gov_solution!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

* Results
display c(current_time)
reghdfe gov_solution grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum gov_solution if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Support non-market-based stimulus") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)








***************************************************** VOTING LEFT (INTENTION) ******************************************************

use "First stage for Analysis.dta", clear

keep unique unique_network vote_* grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if vote_left!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

* Results
display c(current_time)
reghdfe vote_left grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum vote_left if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Intend to vote for left party") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)











***************************************************** VOTED LEFT ******************************************************

* These questions were only asked in 2011 - ie the year before which the shocks definitely occurred before the election

use "First stage for Analysis.dta", clear

keep unique unique_network voted_left_2011 vote_last grossunemp_enter_network grossunemp_enter year both muni muni_network ind2_year ocp_year educ_year

keep if voted_left_2011!=. & grossunemp_enter_network!=.

bysort unique year: egen grossunemp_enter_network_share=mean(grossunemp_enter_network)
drop *_network
duplicates drop unique year, force

tab year 

lab var grossunemp_enter_network_share "Unemployment shock (network share)"

* Results
display c(current_time)
reghdfe voted_left_2011 grossunemp_enter_network_share, absorb(both ind2_year ocp_year educ_year) cluster(muni)
sum voted_left_2011 if e(sample)==1
local mean_outcome=r(mean)
local sd_outcome=r(sd)
sum grossunemp_enter_network_share if e(sample)==1
local mean_shock=r(mean)
local sd_shock=r(sd)
outreg2 using "$output\Table4.xls", append nocons nor ctitle("Voted for left party in 2001") bdec(3) sdec(3) adec(3) label keep(grossunemp_enter_network_share) ///
adds(Outcome mean,`mean_outcome', Outcome sd,`sd_outcome', Unemployment shock mean,`mean_shock',  Unemployment shock sd,`sd_shock')

display c(current_time)









































